/*
 * IDGeneradorTest.cpp

 *
 *      Author: carlos
 */

#include "IDGeneradorTest.h"
#include "../../src/physical_layer/IDGenerator.h"
#include "../../src/utils/types.h"
#include "../../src/utils/ConfigurationMannagerPool.h"
#include <assert.h>
IDGeneradorTest::IDGeneradorTest() {

}

void IDGeneradorTest::run() {

	this->testReset();
	this->testSequenciaIndexTest();
	this->testSequenciaRss();
	this->testSequenciaTweet();
	this->testReset();
	this->testSequenciaIndexTest();
	this->testSequenciaRss();
	this->testSequenciaTweet();
}

IDGeneradorTest::~IDGeneradorTest() {
}

void IDGeneradorTest::testSequenciaRss() {
	int nextId = 0;
	IDGenerator* idGeneratorServicio = IDGenerator::getInstance();
	nextId = idGeneratorServicio->getNextID(
			ConfigurationMannagerPool::getInstance(RSS)->getSequenceName());

	assert(nextId == 1);
	nextId = idGeneratorServicio->getNextID(
			ConfigurationMannagerPool::getInstance(RSS)->getSequenceName());
	assert(nextId == 2);;
	cout << "IDGenerator RSS OK" << endl;
}

void IDGeneradorTest::testSequenciaTweet() {

	int nextId = 0;
	IDGenerator* idGeneratorServicio = IDGenerator::getInstance();
	nextId = idGeneratorServicio->getNextID(
			ConfigurationMannagerPool::getInstance(TWEET)->getSequenceName());

	assert(nextId == 1);
	nextId = idGeneratorServicio->getNextID(
			ConfigurationMannagerPool::getInstance(TWEET)->getSequenceName());
	assert(nextId == 2);;
	cout << "IDGenerator TWEET OK" << endl;
}

void IDGeneradorTest::testReset() {

	//*******Inicio de test reinicio de secuencias******//
	IDGenerator * idGenerator = IDGenerator::getInstance();
	idGenerator->resetAll();
	cout << "Test reset IDGenerator OK" << endl;
}

void IDGeneradorTest::testSequenciaIndexTest() {

	int nextId = 0;
	IDGenerator* idGeneratorServicio = IDGenerator::getInstance();
	nextId =
			idGeneratorServicio->getNextID(
					ConfigurationMannagerPool::getInstance(INDEX_TEST)->getSequenceName());

	assert(nextId == 1);
	nextId =
			idGeneratorServicio->getNextID(
					ConfigurationMannagerPool::getInstance(INDEX_TEST)->getSequenceName());
	assert(nextId == 2);;
	cout << "IDGenerator INDEX_TEST OK" << endl;
}
